<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>新增/修改自然人信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div tabid="tabA" title="基本信息" lselected="true">
                <form id="formSet1">
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="caption">
                            <span class="title">基本信息</span>
                        </div>

                        <div class="fieldBox col_33 col_photo">
                            <div class="label">照片</div>
                            <div class="field">
                                <img src="${defaultHeadPic}" name="mySelfImgUrl" id="mySelfImgUrl"/>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">客户类型</div>
                            <div class="field">
                                <span id="cstTypCdNm" name="cstTypCdNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">姓名</div>
                            <div class="field">
                                <label></label>
                                <span id="cstNm" name="cstNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">性别</div>
                            <div class="field">
                                <span id="genderCdNm" name="genderCdNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">客户关系</div>
                            <div class="field test_combo">
                                <span id="cstRlTypNm" name="cstRlTypNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">证件类型</div>
                            <div class="field">
                                <span id="certTypCdNm" name="certTypCdNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">证件号</div>
                            <div class="field">
                                <span id="certNo" name="certNo">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">手机号</div>
                            <div class="field">
                                <span id="mp1" name="mp1">&nbsp;</span>
                            </div>
                        </div>
                        <%--<div class="fieldBox col_33 col_fix_photo">--%>
                            <%--<div class="label">手机号2</div>--%>
                            <%--<div class="field">--%>
                                <%--<span id="mp2" name="mp2">&nbsp;</span>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">出生日期</div>
                            <div class="field">
                                <span id="birthday" name="birthday">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 ">
                            <div class="label">年龄</div>
                            <div class="field">
                                <span id="age" name="age">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 "col_fix_photo>
                            <div class="label">婚姻情况</div>
                            <div class="field">
                                <span id="marStsCdNm" name="marStsCdNm">&nbsp;</span>
                            </div>
                        </div>



                        <div id="cstGuarDynamicBizdiv" style="display: none">
                            <%-- dynamic field --%>
                        </div>

                        <div id="cstGuar1DynamicBizdiv" style="display: none">
                            <%-- dynamic field --%>
                        </div>



                        <div class="fieldBox col_33 ">
                            <div class="label">还款方式</div>
                            <div class="field">
                                <span id="payTypCd" name="payTypCd">&nbsp;</span>
                            </div>
                        </div>





                        <ui:normalShowSpan pgCd="custNpShowPage" cmpCd="custPagerMainShowForm" cmpDtlCd="cstLvlCd"
                                           orgCds="${orgCds }"></ui:normalShowSpan>

                    </div>


                    <div id="PO_formSet" class="fieldset1 tabel_col tabel_col_s clearFix">
                        <div class="caption">
                            <span class="title">配偶信息</span>
                        </div>


                        <div class="fieldBox col_33">
                            <div class="label">姓名</div>
                            <div class="field">
                                <span id="rl_rlNm" name="rl_rlNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">性别</div>
                            <div class="field">
                                <span id="rl_genderCdNm" name="rl_genderCdNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">证件类型</div>
                            <div class="field">
                                <span id="rl_certTypCdNm" name="rl_certTypCdNm">&nbsp;</span>
                            </div>
                        </div>

                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">证件号</div>
                            <div class="field">
                                <span id="rl_certNo" name="rl_certNo">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">出生日期</div>
                            <div class="field">
                                <span id="rl_birthday" name="rl_birthday">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 col_fix_photo">
                            <div class="label">手机号码</div>
                            <div class="field">
                                <span id="rl_mp" name="rl_mp">&nbsp;</span>
                            </div>
                        </div>

                    </div>
                    <div class="fieldset1 tabel_col tabel_col_s clearFix">
                        <div class="fieldBox col_100" style="display:none;">
                            <div class="field">
                                <input name="cId" id="cId" type="text" class="ui-textbox" value="${id}">
                            </div>
                        </div>

                    </div>
                </form>
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <div class="btnsBox inLC">
                        </div>
                        <span>社会关系/家庭成员</span>
                    </div>
                    <div class="sqPanel_body">
                        <div id="ligergrid_A1" class="sq-grid"></div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<script>
    var pageInApp = {}; // to 下一级子窗口 接口
    var pageInTab = null;
    var loadedTabs = []
    $(function () {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            //minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function (tabid) {
                if (loadedTabs.indexOf(tabid) < 0) {
                    var _cId = $("#cId").val();
                    var _cstNm = $("#cstNm").html();
                    loadedTabs.push(tabid);
                    switch (tabid) {
                        case "tabB":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbank/toCustCstBacInfoNpBankDetailListPage.do?cstId=" + _cId);
                            break;
                        case "tabH":
                            var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCstProjectDetailPage.do" + parms);
                            break;
                        case "tabP":
                            var rlAttrNm = $("#cstRlTypNm").text();
                            if (rlAttrNm.search("担保人") != -1) {
                                var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
                                pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toPrjCstBscDetailPage.do" + parms);
                            } else {
                                $.ligerDialog.SQalert({content: "该客户不是担保人，无担保项目！", SQ_type: "error"});
                            }
                            break;
                        case "tabC":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCustCstBacInfoEpAssetPage.do?cstId=" + _cId);
                            break;
                        case "tabD":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCstCreditPage.do?cstId=" + _cId);
                            break;
                        case "tabF":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstmidmaninfo/toDetailListPage.do?cstId=" + _cId);
                            break;
                        case "tabG":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstcommrec/toDetailListPage.do?cstId=" + _cId);
                            break;
                        case "tabK":
                            var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/risk/rskCstSignLog/toListPage.do" + parms);
                            break;
                        case "tabL":
                            var parms = "?Id=" + _cId + "&useType=1&cstType=1";
                            pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstManualRelation/toListPage.do"+parms);
                            break;
                    }
                }
                ;
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    })

    $(function () {
        $("#formSet1").ligerForm({
            validate: true,
            onAfterSetFields: function () {
                $("#PO_formSet").addClass('Hide');
            }
        });

        //初始化数据
        initData();
        initEvent();

        ligergrid_A1();
        initCstCreditTip();
    });

    //查询客户是否有逾期记录,如果有则显示闪灯提醒
    function initCstCreditTip() {
        //SQ.add_tabFlasher({
        //    ligerTab: pageInTab, //ligerTab实例对象
        //    tabid: 'tabDId', //目标tabid
        //    tip: '可以写提示哦~'
        //});
    };

    function ligergrid_A1() {
        var _cId = $("#cId").val();
        $("#ligergrid_A1").ligerGrid({
            usePager: false,
            parms: {cstId: _cId},
            url: '<%=path%>/customer/cstnpsocialrl/initList.do?isEncrypt=1',
            method: 'get',
            columns: [{
                display: '关系',
                name: 'rlTypCdNm',
                isSort: false,
                width: 120, render: function (rowdata, rowindex, value, column) {
                    var h = '';
                    h = '<a  href="javascript:cstRlDetailBtnEvent(';
                    h += "'" + rowdata.id + "'";
                    h += ')">' + value + '</a>'
                    return h;
                }
            }, {
                display: '姓名',
                name: 'rlNm',
                isSort: false,
                minWidth: 60,
                align: 'center', render: function (rowdata, rowindex, value, column) {
                    var h = value;
                    if (StringUtils.isNotEmpty(rowdata.rlCstId)) {
                        h = '<a  href="javascript:toCstDetailBtnEvent(';
                        h += "'" + rowdata.rlCstId + "'";
                        h += ')">' + value + '</a>'
                    }
                    return h;
                }
            }, {
                display: '手机号',
                name: 'mp',
                isSort: false,
                width: 150,
            }
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            isScroll: false,
            checkbox: true,
            rownumbers: true,
            onAfterShowData: function () {
                if (parent.mainApp) parent.mainApp.parentTab.onResize();
            }
        });
        npSocialRlGrid = liger.get("ligergrid_A1");
    }

    //初始化事件
    function initEvent() {
    }

    //社会关系详细
    function cstRlDetailBtnEvent(_id) {
        $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 800,
            height: 380,
            title: '社会关系/家庭成员',
            url: '<%=path%>/customer/cstnpsocialrl/toDetailPage.do?rId=' + _id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
                onclick: function (item, Dialog) {
                    //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                    if (Dialog.onCancel) Dialog.onCancel();
                }
            }
            ]

        });
    }


    function initData() {
        var _id = $("#cId").val();
        if (!_id) return;
        var _url = '<%=path%>/customer/cstbscinfo/getShowDetailById.do?isEncrypt=1';
        AjaxUtils.ajaxGet(_url, {id: _id}, function (msg) {
            if (msg.success == 1) {
                setData(msg.data);//设置数据
            } else {
                UIUtils.alertError(msg.info);
            }
        }, true);
    }

    //到客户查看页面
    function toCstDetailBtnEvent(_cstId) {
        Add_navTab('tab_cst_detail' + _cstId, '客户详情', '<%=path%>/customer/cstbscinfo/toCustDetailPage.do?id=' + _cstId);
    }

    //设置页面数据
    function setData(data) {
        $("#cstTypCdNm").html(data.cstTypCdNm);
        $("#cstLvlCdNm").html(data.cstLvlCdNm);
        $("#indCdNm").html(data.indCdNm);
        $("#payTypCd").html(data.payTypCdNm);
        if (data.indCdNm == LogUtils.LOG_CUST_SELECT_OTHER_VALUE) {
            $("#othIndCd").html(data.othIndCd);
        }
        $("#marStsCdNm").html(data.cstNpBscInfoVO.marStsCdNm);
        $("#cstStsCdNm").html(data.cstStsCdNm);
        $("#certTypCdNm").html(data.certTypCdNm);
        $("#cstCdNm").html(data.cstCdNm);
        $("#zipNo").html(data.cstNpBscInfoVO.zipNo);
        $("#homeTel").html(data.cstNpBscInfoVO.homeTel);
        $("#certNo").html(data.certNo);
        $("#age").html(data.cstNpBscInfoVO.age);
        $("#workTel").html(data.cstNpBscInfoVO.workTel);
        $("#workPlc").html(data.cstNpBscInfoVO.workPlc);
        $("#idAddr").html(data.cstNpBscInfoVO.idAddr);
        $("#homeAddr").html(data.cstNpBscInfoVO.homeAddr);
        $("#postAddr").html(data.cstNpBscInfoVO.postAddr);
        $("#workAddr").html(data.cstNpBscInfoVO.workAddr);
        $("#cstRlTypNm").html(data.cstRlAttrNm);
        $("#mp1").html(data.cstNpBscInfoVO.mp1);
        $("#mp2").html(data.cstNpBscInfoVO.mp2);
        $("#cstRem").html(data.cstRem);
        $("#workYrs").html(data.cstNpBscInfoVO.workYrs);
        $("#eduLvlCdNm").html(data.cstNpBscInfoVO.eduLvlCdNm);
        $("#cstNm").html(data.cstNm);
        $("#genderCdNm").html(data.cstNpBscInfoVO.genderCdNm);
        $("#ocpCdNm").html(data.cstNpBscInfoVO.ocpCdNm);
        $("#posCdNm").html(data.cstNpBscInfoVO.posCdNm);
        $("#titCdNm").html(data.cstNpBscInfoVO.titCdNm);
        $("#homeTel").html(data.cstNpBscInfoVO.homeTel);
        $("#titCdNm").html(data.cstNpBscInfoVO.workTel);
        $("#isSmallBusCdNm").html(data.cstNpBscInfoVO.isSmallBusNm);

        if (data.cstNpBscInfoVO.birthday) {
            var date = new Date(data.cstNpBscInfoVO.birthday);
            var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            $("#birthday").html(dateStr);
        }

        //我自己的身份证照片
        if (data.mySelfIDImgUrl) {
            $("#mySelfImgUrl").attr('src', data.mySelfIDImgUrl);
        }

        //我配偶的身份证照片
        if (data.myPeiOuIDImgUrl) {
            $("#myPeiOuImgUrl").attr('src', data.myPeiOuIDImgUrl);
        }
        $("#highDgCd").html(data.cstNpBscInfoVO.highDgCdNm);
        $("#livCndCd").html(data.cstNpBscInfoVO.livCndCdNm);
        $("#cstLvlCd").html(data.cstLvlCdNm);
        $("#email").html(data.cstNpBscInfoVO.email);
        $("#yrInc").html(data.cstNpBscInfoVO.yrIncStr);
        $("#officeZip").html(data.cstNpBscInfoVO.officeZip);
        $("#workStYr").html(data.cstNpBscInfoVO.workStYr);
        $("#homeZip").html(data.cstNpBscInfoVO.homeZip);

        //显示配偶信息
        if (data.cstNpBscInfoVO.cstNpSocialRlVO) {
            $("#rl_rlNm").html(data.cstNpBscInfoVO.cstNpSocialRlVO.rlNm);
            $("#rl_certTypCdNm").html(data.cstNpBscInfoVO.cstNpSocialRlVO.certTypCdNm);
            $("#rl_genderCdNm").html(data.cstNpBscInfoVO.cstNpSocialRlVO.genderCdNm);
            $("#rl_certNo").html(data.cstNpBscInfoVO.cstNpSocialRlVO.certNo);
            $("#rl_mp").html(data.cstNpBscInfoVO.cstNpSocialRlVO.mp);
            $("#rl_workPlc").html(data.cstNpBscInfoVO.cstNpSocialRlVO.workPlc);
            $("#rl_tel").html(data.cstNpBscInfoVO.cstNpSocialRlVO.tel);
            $("#rl_idAddr").html(data.cstNpBscInfoVO.cstNpSocialRlVO.idAddr);
            $("#rl_workAddr").html(data.cstNpBscInfoVO.cstNpSocialRlVO.workAddr);
            $("#rl_rlRem").html(data.cstNpBscInfoVO.cstNpSocialRlVO.rlRem);
            $("#rl_birthday").html(data.cstNpBscInfoVO.cstNpSocialRlVO.birthday);
        }

        var marriageState_val = data.cstNpBscInfoVO.marStsCd
        if (marriageState_val == CustomerConstant.CST_MAR_STS_CD_2
            || marriageState_val == CustomerConstant.CST_MAR_STS_CD_first
            || marriageState_val == CustomerConstant.CST_MAR_STS_CD_agian
            || marriageState_val == CustomerConstant.CST_MAR_STS_CD_back
        ) {
            $("#PO_formSet").removeClass('Hide');
        } else {
            var formSet1 = liger.get("formSet1");
            ;
        }

        if (data.cstRlAttr) {
            var tempGuarTypCd = data.cstExtInfoVO.guarTypCdNm;
            var tempGuarAmt = data.cstExtInfoVO.num9;
            tempGuarAmt = NumberUtils.isScientificNotationToString(tempGuarAmt);
            if (data.cstRlAttr.indexOf(CustomerConstant.CST_RL_TYPE_DBR_CD) != -1) {
                var _url = '<%=path%>/customer/cstbscinfo/toCstGuarDetailDynamicPage.do';
                //如果有参数则在第二个参数中传入


                //重新赋值使用
                var tempSchr7Nm = data.cstExtInfoVO.schr7Nm;
                var tempUsedNm = data.cstNpBscInfoVO.usedNm;
                var tempDrvLicTyp = data.cstNpBscInfoVO.drvLicTyp;
                var tempNation = data.cstNpBscInfoVO.nation;
                _url = '<%=path%>/customer/cstbscinfo/toCstDetailDynamicPageForNp.do';
                //如果有参数则在第二个参数中传入
                $("#cstGuar1DynamicBizdiv").load(_url, {bizCd: CustomerConstant.CST_RL_TYPE_DBR_CD}, function (responseText, textStatus) {
                    $("#schr7").html(tempSchr7Nm);
                    $("#usedNm").html(tempUsedNm);
                    $("#drvLicTyp").html(tempDrvLicTyp);
                    $("#nation").html(tempNation);
                });
            }


        }

        //设置客户关系中的立项控制
        if (data.cstRlAttrVOList) {
            $("#prjCtrlCd").html(data.prjCtrlCdNm);
        }

        //辅助信息
        if (data.cstExtInfoVO) {
            $("#ext_schr1").html(data.cstExtInfoVO.schr1);
            $("#ext_schr2").html(data.cstExtInfoVO.schr2);
            $("#ext_schr3").html(data.cstExtInfoVO.schr3);
            $("#ext_schr4").html(data.cstExtInfoVO.schr4);
            $("#ext_schr5").html(data.cstExtInfoVO.schr5);
            $("#ext_mchr1").html(data.cstExtInfoVO.mchr1);
            $("#ext_mchr2").html(data.cstExtInfoVO.mchr2);
            $("#ext_mchr3").html(data.cstExtInfoVO.mchr3);
            $("#ext_mchr4").html(data.cstExtInfoVO.mchr4);
            $("#ext_mchr5").html(data.cstExtInfoVO.mchr5);
            $("#ext_mchr6").html(data.cstExtInfoVO.mchr6);
            $("#ext_mchr7").html(data.cstExtInfoVO.mchr7);
            $("#ext_mchr8").html(data.cstExtInfoVO.mchr8);
            $("#ext_bchr1").html(data.cstExtInfoVO.bchr1);
            $("#ext_bchr2").html(data.cstExtInfoVO.bchr2);
            $("#ext_bchr3").html(data.cstExtInfoVO.bchr3);
            $("#ext_num1").html(data.cstExtInfoVO.num1);
            $("#ext_num2").html(data.cstExtInfoVO.num2);
            $("#ext_num3").html(data.cstExtInfoVO.num3);
            $("#ext_num4").html(data.cstExtInfoVO.num4);
            $("#ext_num5").html(data.cstExtInfoVO.num5);
            $("#ext_num6").html(data.cstExtInfoVO.num6);
            $("#ext_num7").html(data.cstExtInfoVO.num7);
            $("#ext_num8").html(data.cstExtInfoVO.num8);
            $("#ext_num9").html(data.cstExtInfoVO.num9);
            $("#ext_num10").html(data.cstExtInfoVO.num10);
            $("#ext_num11").html(data.cstExtInfoVO.num11);
            $("#ext_num12").html(data.cstExtInfoVO.num12);
            $("#ext_num13").html(data.cstExtInfoVO.num13);
            $("#ext_num14").html(data.cstExtInfoVO.num14);
            $("#ext_num15").html(data.cstExtInfoVO.num15);
        }
    }
</script>
</body>
</html>